#include "x51AppMgr.h"

CX51AppMgr* CX51AppMgr::g_app_mgr = nullptr;

CX51AppMgr::CX51AppMgr()
{

}

CX51AppMgr::~CX51AppMgr()
{

}

CX51AppMgr* CX51AppMgr::GetInstance()
{
	if (g_app_mgr == nullptr)
	{
		g_app_mgr = new CX51AppMgr();
	}

	return g_app_mgr;
}

void CX51AppMgr::Clear()
{
	if (g_app_mgr)
	{
		g_app_mgr->UnInit();
		delete g_app_mgr;
		g_app_mgr = nullptr;
	}
}

void CX51AppMgr::Init()
{
	m_net_protocol_mgr.Init();
	m_socket_mgr.AddHookSystemFunc();
	HookSocketInfo();
}

void CX51AppMgr::UnInit()
{
	m_net_protocol_mgr.Uninit();
	UnHookSocketInfo();
}

CDetourHookFunctionCtrl* CX51AppMgr::GetHookFunCtrl()
{
	return &m_func_ctrl;
}

CProtocolMgr* CX51AppMgr::GetProtocolMgr()
{
	return &m_net_protocol_mgr;
}

CX51SocketInfoMgr* CX51AppMgr::GetSocketInfoMgr()
{
	return &m_socket_mgr;
}

void CX51AppMgr::HookSocketInfo()
{
	m_socket_mgr.AddHookSystemFunc();
	m_func_ctrl.InitHook();

}

void CX51AppMgr::UnHookSocketInfo()
{
	m_func_ctrl.UninitHook();
}

